package com.sise.stuteaintersys.mapper;

import com.sise.stuteaintersys.bean.entity.Student;
import com.sise.stuteaintersys.bean.entity.StudentExample;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface StudentMapper {
    int countByExample(StudentExample example);

    int deleteByExample(StudentExample example);

    int deleteByPrimaryKey(Integer id);

    int insert(Student record);

    int insertSelective(Student record);

    List<Student> selectByExample(StudentExample example);

    Student selectByPrimaryKey(Integer id);

    Integer selectIdByName(String name);
    @Select("select * from student where login_name=#{name}")
    Student selectPasswordByLoginName(String loginName);

    int updateByExampleSelective(@Param("record") Student record, @Param("example") StudentExample example);

    int updateByExample(@Param("record") Student record, @Param("example") StudentExample example);

    int updateByPrimaryKeySelective(Student record);

    int updateByPrimaryKey(Student record);

    /**
     * 查询所有学生
     * @return
     */
    @Select("SELECT * FROM student")
    List<Student> findAll();

    /**
     * 根据姓名模糊查询
     * @param name
     * @return
     */
    @Select("SELECT * FROM student WHERE student.name LIKE concat(concat('%',#{name}),'%')")
    List<Student> findStudents(String name);

    /**
     * 根据姓名进行查询
     * @param name
     * @return
     */
    @Select("SELECT * FROM student WHERE student.login_name =#{name}")
    List<Student> checkStudent(String name);
}